package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Jiaoshi;
import com.ruoyi.system.service.IJiaoshiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教师Controller
 * 
 * @author ruoyi
 * @date 2024-10-12
 */
@RestController
@RequestMapping("/system/jiaoshi")
public class JiaoshiController extends BaseController
{
    @Autowired
    private IJiaoshiService jiaoshiService;

    /**
     * 查询教师列表
     */
    @PreAuthorize("@ss.hasPermi('system:jiaoshi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Jiaoshi jiaoshi)
    {
        startPage();
        List<Jiaoshi> list = jiaoshiService.selectJiaoshiList(jiaoshi);
        return getDataTable(list);
    }

    /**
     * 导出教师列表
     */
    @PreAuthorize("@ss.hasPermi('system:jiaoshi:export')")
    @Log(title = "教师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Jiaoshi jiaoshi)
    {
        List<Jiaoshi> list = jiaoshiService.selectJiaoshiList(jiaoshi);
        ExcelUtil<Jiaoshi> util = new ExcelUtil<Jiaoshi>(Jiaoshi.class);
        util.exportExcel(response, list, "教师数据");
    }

    /**
     * 获取教师详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:jiaoshi:query')")
    @GetMapping(value = "/{jiaoshiId}")
    public AjaxResult getInfo(@PathVariable("jiaoshiId") Long jiaoshiId)
    {
        return success(jiaoshiService.selectJiaoshiByJiaoshiId(jiaoshiId));
    }

    /**
     * 新增教师
     */
    @PreAuthorize("@ss.hasPermi('system:jiaoshi:add')")
    @Log(title = "教师", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jiaoshi jiaoshi)
    {
        return toAjax(jiaoshiService.insertJiaoshi(jiaoshi));
    }

    /**
     * 修改教师
     */
    @PreAuthorize("@ss.hasPermi('system:jiaoshi:edit')")
    @Log(title = "教师", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jiaoshi jiaoshi)
    {
        return toAjax(jiaoshiService.updateJiaoshi(jiaoshi));
    }

    /**
     * 删除教师
     */
    @PreAuthorize("@ss.hasPermi('system:jiaoshi:remove')")
    @Log(title = "教师", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jiaoshiIds}")
    public AjaxResult remove(@PathVariable Long[] jiaoshiIds)
    {
        return toAjax(jiaoshiService.deleteJiaoshiByJiaoshiIds(jiaoshiIds));
    }
}
